package com.pattern.proxy.dynamic;

import com.pattern.proxy.staticproxy.ITeacherDao;

/**
 * @author 冯志立
 * @create 2019-11-09 9:54
 */
public class Client {
    public static void main(String[] args) {
        //创建一个目标对象
        ITeacherDao target = new TeacherDao();
        //给目标对象创建代理对象,可以转成ITeacherDao
        ITeacherDao proxyInstance = (ITeacherDao) new ProxyFactory(target).getProxyInstance();

        //从此处可以看出，内存中动态生成了代理对象
        System.out.println("ProxyInstance=" + proxyInstance.getClass());

        //通过代理对象，调用目标对象的方法

        proxyInstance.teach();


    }
}
